-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[20310] Feature: topic keys with non breaking ABI #2
base: vulcanexus
Are you sure you want to change the base?
Conversation
rosidl_typesupport_fastrtps_c/include/rosidl_typesupport_fastrtps_c/identifier.h
Show resolved
Hide resolved
rosidl_typesupport_fastrtps_cpp/include/rosidl_typesupport_fastrtps_cpp/identifier.hpp
Show resolved
Hide resolved
rosidl_typesupport_fastrtps_cpp/resource/msg__type_support.cpp.em
Outdated
Show resolved
Hide resolved
rosidl_typesupport_fastrtps_cpp/resource/msg__type_support.cpp.em
Outdated
Show resolved
Hide resolved
/// Callback function for message serialization | ||
/** | ||
* \param[in] untyped_ros_message Type erased pointer to message instance. | ||
* \param [in,out] Serialized FastCDR data object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Callback function for message serialization | |
/** | |
* \param[in] untyped_ros_message Type erased pointer to message instance. | |
* \param [in,out] Serialized FastCDR data object. | |
/// Callback function for key serialization | |
/** | |
* \param [in] untyped_ros_message Type erased pointer to message instance. | |
* \param [in,out] Serialized FastCDR data object. |
/// Callback function for message deserialization | ||
/** | ||
* \param [in] Serialized FastCDR data object. | ||
* \param[out] untyped_ros_message Type erased pointer to message instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Callback function for message deserialization | |
/** | |
* \param [in] Serialized FastCDR data object. | |
* \param[out] untyped_ros_message Type erased pointer to message instance. | |
/// Callback function for key deserialization | |
/** | |
* \param [in] Serialized FastCDR data object. | |
* \param [out] untyped_ros_message Type erased pointer to message instance. |
|
||
/// Callback function to get size of the key data | ||
/** | ||
* \return The size of the serialized message in bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add corresponding \param
descriptions here
|
||
struct message_type_support_key_callbacks_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary
struct message_type_support_key_callbacks_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
@@ -90,6 +104,89 @@ namespace @(ns) | |||
@{forward_declared_types.add(message.structure.namespaced_type.namespaced_name())}@ | |||
namespace typesupport_fastrtps_cpp | |||
{ | |||
@{ | |||
def generate_member_for_cdr_serialize(member, suffix): | |||
from rosidl_generator_cpp import msg_type_only_to_cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation of this python method
static | ||
size_t | ||
_@(message.structure.namespaced_type.name)__get_serialized_size_key( | ||
const void * untyped_ros_message, | ||
size_t initial_alignment) | ||
{ | ||
auto typed_message = | ||
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>( | ||
untyped_ros_message); | ||
|
||
return static_cast<uint32_t>(get_serialized_size_key(*typed_message, initial_alignment)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static | |
size_t | |
_@(message.structure.namespaced_type.name)__get_serialized_size_key( | |
const void * untyped_ros_message, | |
size_t initial_alignment) | |
{ | |
auto typed_message = | |
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>( | |
untyped_ros_message); | |
return static_cast<uint32_t>(get_serialized_size_key(*typed_message, initial_alignment)); | |
} | |
static | |
size_t | |
_@(message.structure.namespaced_type.name)__get_serialized_size_key( | |
const void * untyped_ros_message) | |
{ | |
auto typed_message = | |
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>( | |
untyped_ros_message); | |
return get_serialized_size_key(*typed_message, 0); | |
} |
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key( | ||
size_t current_alignment, | ||
bool & is_unbounded) | ||
{ | ||
bool full_bounded = true; | ||
bool is_plain = true; | ||
|
||
size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)( | ||
full_bounded, | ||
is_plain, | ||
current_alignment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key( | |
size_t current_alignment, | |
bool & is_unbounded) | |
{ | |
bool full_bounded = true; | |
bool is_plain = true; | |
size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)( | |
full_bounded, | |
is_plain, | |
current_alignment); | |
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key( | |
bool & is_unbounded) | |
{ | |
bool full_bounded = true; | |
bool is_plain = true; | |
size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)( | |
full_bounded, | |
is_plain, | |
0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also changed it in the c interfaces
@@ -162,6 +177,134 @@ const rosidl_message_type_support_t * | |||
|
|||
using _@(message.structure.namespaced_type.name)__ros_msg_type = @('__'.join(message.structure.namespaced_type.namespaced_name())); | |||
|
|||
@{ | |||
def generate_member_for_cdr_serialize(member, suffix): | |||
from rosidl_generator_cpp import msg_type_only_to_cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation for this python method
if suffix == '': | ||
strlist.append(' if (!callbacks->cdr_serialize(') | ||
else: | ||
strlist.append(' if (!callbacks->%s_callbacks->cdr_serialize%s(' % ((''.join(c for c in suffix if c not in '(){}<>_*')), suffix)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware! callbacks->key_callbacks
might be nullptr!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applies elsewhere
return current_alignment - initial_alignment; | ||
} | ||
|
||
@[ if message.structure.has_any_member_with_annotation('key') ]@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should follow the same approach we are using for the cpp
type support, i.e. always declaring and exporting the type-aware implementations, and then generate the void *
implementations when the type has a key
annotation.
This would imply changing the way we call nested types and making it not rely on the callbacks structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, lets give it a try. Then, not applying the former comment
…ethod Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
…s for supporting keys Signed-off-by: Mario Dominguez <[email protected]>
…ods for supporting keys Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
… structure Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
…erialized Signed-off-by: Mario Dominguez <[email protected]>
…called from outside in headers Signed-off-by: Mario Dominguez <[email protected]>
…rations Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_cdr_serialize Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_get_serialized_size Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_max_serialized_size Signed-off-by: Mario Dominguez <[email protected]>
…llback structure Signed-off-by: Mario Dominguez <[email protected]>
…alize_key and cdr_deserialize_key methods that are not going to be used nor exported if the type do not have keys Signed-off-by: Mario Dominguez <[email protected]>
…e called from outside in headers Signed-off-by: Mario Dominguez <[email protected]>
…larations Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_cdr_serialize. Also, generate proxy methods only when the type has a key Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_get_serialized_size adn proxy Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_max_serialized_size and proxy Signed-off-by: Mario Dominguez <[email protected]>
…ey method and proxy Signed-off-by: Mario Dominguez <[email protected]>
…callback structure Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
9a332c7
to
491fea2
Compare
This PR brings the changes in the
rosidl_typesupport_fastrtps
generator packages to support topic keys feature without breaking ABI.Note: This branch starts from the previous work from #1